const webpackMerge = require('webpack-merge');
const commonConfig = require('./base.js');
var path = require('path');
const webpack = require('webpack')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const productionGzipExtensions = /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i;

module.exports = function(env) {
	return webpackMerge(commonConfig, {
		mode: 'production',
		plugins: [
			new webpack.LoaderOptionsPlugin({
				minimize: true,
				debug: false
			}),
			new BundleAnalyzerPlugin(),
			new webpack.ContextReplacementPlugin(
				/moment[/\\]locale$/,
				/zh-cn/,
				/en-au/,
			),
			new CompressionWebpackPlugin({
				filename: '[path].gz[query]',
				algorithm: 'gzip',
				test: productionGzipExtensions,
				threshold: 2048,
				minRatio: 0.8
			})
		]
	})
}

